#ifndef __ACTIVE_OBSERVABLE__
#define  __ACTIVE_OBSERVABLE__

#include <e32base.h>

class CActiveObservable;

class MActiveObserver
{
public:
	virtual void DoCancel(CActiveObservable* self) = 0;  
	virtual void RunL(CActiveObservable* self) = 0;
};
class CActiveObservable : public CActive
{
public:
	CActiveObservable() : CActive(EPriorityLow), iObserver(NULL)
	{
		CActiveScheduler::Add(this);
	}
	void DoCancel() { if (iObserver) iObserver->DoCancel(this); }
	void RunL() { if (iObserver) iObserver->RunL(this); }
	void Activate() { SetActive(); }
	virtual ~CActiveObservable() { Cancel(); }
	void SetObserver(MActiveObserver* aObserver) { iObserver = aObserver; }
protected:
	MActiveObserver* iObserver;		
};

#endif //__ACTIVE_OBSERVABLE__
